export default {
	data () {
		return {
			dataList: [],
			statusInfo: {
				dataLoading: false,
				pullUpLoading: false,
				dataLoaded: false,
				noData: false,
				finished: false,
				error: false
			},
			pageInfo: {
				pageIndex: 1,
				pageSize: 20,
				total: 0
			}
		}
	},
	methods: {
		async getPageDataList (more = false, body = {}) {
			if (!args.interfaceName) return
			statusInfo.pullUpLoading = true
			statusInfo.dataLoading = true
			const params = {
				// pageSize: pageInfo.pageSize,
				pageIndex: more === true ? pageInfo.pageIndex + 1 : pageInfo.startPageIndex,
				...body
			}
			Object.keys(filterInfo).forEach(e => {
				if (!['', null, undefined].includes(filterInfo[e])) {
					params[e] = filterInfo[e]
				}
			})
			const [res] = await args.interfaceApi[args.interfaceName](params)
			// 请求完成标记
			if (!statusInfo.dataLoaded) {
				statusInfo.dataLoaded = true
			}
			if (res._errCode === '0') {
				const data = res._data.orderList || []
				const total = Number(res._data.pageInfo?.total || 0)
				list.value = more === true ? list.value.concat(data) : data
				pageInfo.pageIndex = params.pageIndex
				pageInfo.total = total
				// 异常重新请求错误转态重置
				if (statusInfo.error) {
					statusInfo.error = false
				}
				// 暂无数据
				if (list.value.length === 0) {
					statusInfo.noData = true
					statusInfo.finished = true
				} else if (list.value.length >= total) {
					// 全部数据加载完毕
					statusInfo.finished = true
				}
				eventInfo.onSuccess && eventInfo.onSuccess(res._data)
			} else {
				statusInfo.error = true
			}
			statusInfo.pullUpLoading = false
			statusInfo.dataLoading = false
		}
	}
}